package com.xbq.exceleditor

import android.os.Bundle
import androidx.fragment.app.Fragment
import com.blankj.utilcode.util.ActivityUtils
import com.github.appintro.AppIntro
import com.github.appintro.AppIntroFragment
import com.github.appintro.AppIntroPageTransformerType
import com.gyf.immersionbar.ktx.immersionBar

/**
 * Author: liaohaiping
 * Time: 2021-01-14
 * Description:
 */
class AppIntroActivity:AppIntro() {

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        immersionBar{}
        setTransformer(AppIntroPageTransformerType.SlideOver)
        var titleColor = resources.getColor(R.color.intro_titleColor)
        var descriptionColor = resources.getColor(R.color.intro_descriptionColor)
        var backgroundColor = resources.getColor(R.color.intro_backgroundColor)

        addSlide(AppIntroFragment.newInstance(
            title = resources.getString(R.string.intro1_title),
            description = resources.getString(R.string.intro1_description),
            imageDrawable = R.drawable.ic_intro1,
            backgroundDrawable = R.drawable.bg_mine_center,
            titleColor = titleColor,
            descriptionColor = descriptionColor,
            backgroundColor =backgroundColor,
        ))
        addSlide(AppIntroFragment.newInstance(
            title = resources.getString(R.string.intro2_title),
            description = resources.getString(R.string.intro2_description),
            imageDrawable = R.drawable.ic_intro2,
            backgroundDrawable = R.drawable.bg_mine_center,
            titleColor = titleColor,
            descriptionColor = descriptionColor,
            backgroundColor =backgroundColor,
        ))
        addSlide(AppIntroFragment.newInstance(
            title = resources.getString(R.string.intro3_title),
            description = resources.getString(R.string.intro3_description),
            imageDrawable = R.drawable.ic_intro3,
            backgroundDrawable = R.drawable.bg_mine_center,
            titleColor = titleColor,
            descriptionColor = descriptionColor,
            backgroundColor =backgroundColor,
        ))
        addSlide(AppIntroFragment.newInstance(
            title = resources.getString(R.string.intro4_title),
            description = resources.getString(R.string.intro4_description),
            imageDrawable = R.drawable.ic_intro4,
            backgroundDrawable = R.drawable.bg_mine_center,
            titleColor = titleColor,
            descriptionColor = descriptionColor,
            backgroundColor =backgroundColor,
        ))
    }

    override fun onSkipPressed(currentFragment: Fragment?) {
        super.onSkipPressed(currentFragment)
        // Decide what to do when the user clicks on "Skip"
        ActivityUtils.startActivity(MainActivity::class.java)
        finish()
    }

    override fun onDonePressed(currentFragment: Fragment?) {
        super.onDonePressed(currentFragment)
        // Decide what to do when the user clicks on "Done"
        ActivityUtils.startActivity(MainActivity::class.java)
        finish()
    }

    override fun onDestroy() {
        super.onDestroy()
    }
}